﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Mail;

namespace Forest.Core
{
    public class MailHelper
    {
        /// <summary>
        /// 发送邮件
        /// </summary>
        /// <param name="toAddress">目标邮件地址</param>
        /// <param name="subject">标题</param>
        /// <param name="body">正文内容</param>
        public static void SendMail(String toAddress, String subject, String body)
        {
            var smtp = new SmtpClient(); //实例化一个SmtpClient
            var mailMessage = new MailMessage(); //实例化一个邮件类
            mailMessage.To.Add(new MailAddress(toAddress));
            mailMessage.Subject = subject; //邮件标题
            mailMessage.SubjectEncoding = Encoding.UTF8;
            mailMessage.BodyEncoding = Encoding.UTF8;
            mailMessage.Body = body;
            smtp.Send(mailMessage);
        }
    }
}
